-
Notifications
You must be signed in to change notification settings - Fork 898
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for v2v pre/post Ansible playbook service. #17627
Conversation
@lfu Looks good. You have more coming up, right? |
49486b1
to
48aaeed
Compare
@bzwei Ready for final review. |
@@ -20,6 +20,14 @@ def transformation_destination(source_obj) | |||
miq_request.transformation_mapping.destination(source_obj) | |||
end | |||
|
|||
def pre_ansible_playbook_service_template |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to expose the methods in service model.
@@ -52,6 +55,14 @@ | |||
it { expect(task.transformation_destination(src)).to eq(dst) } | |||
end | |||
|
|||
describe '#pre_ansible_playbook_service_template' do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add negative test where pre/post_service_id
are not configured.
cc @fdupont-redhat |
48aaeed
to
52ab78d
Compare
@bzwei Updated. |
service_template.create_resource_actions(enhanced_config_info) | ||
end | ||
end | ||
end | ||
|
||
def add_vm_resource(vm) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move this logic into #validate_config_info
52ab78d
to
163376f
Compare
# :vm_ids | ||
# :pre_service_id | ||
# :post_service_id | ||
# :tasks => [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are overloading the term tasks
here since the migration is built on request/request_task modeling. I suggest renaming this to actions
.
config_info[:vms] | ||
end | ||
pre_service_id = config_info[:pre_service] ? config_info[:pre_service].id : config_info[:pre_service_id] | ||
post_service_id = config_info[:post_service] ? config_info[:post_service_id].id : config_info[:post_service_id] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When do we have the pre_service
object and when do we only get passed the pre_service_id
?
Could these lines be simplified to this format:
pre_service_id = config_info[:pre_service].try(:id) || config_info[:pre_service_id]
next if vm_obj.nil? | ||
|
||
vm_options = {} | ||
vm_options[:pre_ansible_playbook_service_template_id] = pre_service_id if vm_hash[:pre_service] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bzwei Instead of passing the service template id down into each task would it make sense to just capture the :pre_service
and :post_service
flags for each and at runtime do the lookup from the associated plan.
Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we only store an id, it makes no big difference to use id vs boolean, but it saves extra logic to resolve the id at runtime.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking about having to keep the id in-sync across all the records if someone edited the plan and selected a new service. You would not need to adjust each task and the value is really only looked up once during the run so the overhead at that time is minimal.
163376f
to
d987c56
Compare
|
||
vms = [] | ||
if config_info[:actions] | ||
vm_objects = VmOrTemplate.where(:id => config_info[:actions].collect { |vm_hash| vm_hash[:vm_id] }.compact) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can make vm_objects
a hash rather than an array. Then in Ln 89 you can directly lookup the object without a looping.
Ln 88 could be as simple as vm_obj = vm_objects[vm_hash[:vm_id]] || vm_hash[:vm]
d987c56
to
11a51c0
Compare
11a51c0
to
64d12b1
Compare
Checked commit lfu@64d12b1 with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0 |
LGTM |
@miq-bot add_label gaprindashvili/yes |
Support for v2v pre/post Ansible playbook service. (cherry picked from commit ce4d2b5) https://bugzilla.redhat.com/show_bug.cgi?id=1608420
Gaprindashvili backport details:
|
Includes ManageIQ/manageiq-automation_engine#192.
https://bugzilla.redhat.com/show_bug.cgi?id=1564250
@miq-bot assign @gmcculloug
@miq-bot add_label enhancement, transformation